{% extends "telechat/base_telechat.html" %}
{% load ietf_filters %}

{% block breadcrumbs %}{{ block.super }}
    &raquo; {{ date }}
{% endblock %}

{% block subsection %}
    <div id="telechat-content">
        {% if document %}
            {% if not nav_start %}<a href="./previous/">&laquo; Previous</a>{% endif %}
            {% if not nav_end %}<span class="right-nav"><a href="./next/">Next &raquo;</a></span>{% endif %}
            <br>
            <h3>
                {% for line in header %}
                    {{ line }}<br>
                {% endfor %}
            </h3>
            <br>
            <h3>{{ document.name }}-{{ document.rev }} ({{ document.intended_std_level }})</h3>
            {% if conflictdoc %}References: <a href="{{ conflictdoc.get_absolute_url }}">{{ conflictdoc }}</a><br>{% endif %}
            <a href="#writeup">Ballot Writeup</a><br>
            Token: {{ document.ad.name }}<br>
            {% if document.type_id == "draft" %}
                Consensus: {{ document|consensus }}<br>
                Has downref: {% if downrefs %}Yes{% else %}No{% endif %}<br>
            {% endif %}
            Number of Open Positions: {{ open_positions }}<br>
            <br>
            <div>
                <form method="post">{% csrf_token %}
                    {{ formset.management_form }}
                    <table id="telechat-positions-table">
                        <tbody>
                        <tr>
                            <th scope="col">Area Director</th>
                            {% for position in document.active_ballot.ballot_type.positions.all %}
                                <th scope="col">{{ position.name }}</th>
                            {% endfor %}
                        </tr>
                        {% for form in formset.forms %}
                            <tr{% if form.initial.position == 'norecord' or form.initial.position == None %} class="green-row"{% endif %}{% if form.initial.position == 'discuss' %} class="red-row"{% endif %}><td>{{ form.initial.name }}{{ form.name }}{{ form.id }}</td>
                                {% with form.position as field %}
                                    {% for choice in field.field.choices %}
                                        <td><input type="radio" {% if form.initial.position == choice.0 %}checked {% endif %}id="id_{{ field.html_name }}_{{ forloop.counter0 }}" value="{{ choice.0 }}" name="{{ field.html_name }}"></td>
                                    {% endfor %}
                                {% endwith %}
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
                <div class="telechat-button">
                    <ul><li><button type="submit" name="submit" value="update_ballot">Update Ballot</button></li></ul>
                </div>
            </form>
            </div>

            <hr><br>

            <!-- [html-validate-disable-block wcag/h32 -- FIXME: no submit button] -->
            <form method="post">{% csrf_token %}
                <table>
                    <tbody>
                    <!-- [html-validate-disable-block wcag/h63 -- FIXME: as_table renders without scope] -->
                    {{ state_form.as_table }}
                    </tbody>
                </table>
                <div class="telechat-button">
                    <ul><li><button type="submit" name="submit" value="update_state">Update State</button></li></ul>
                </div>
            </form>

            <hr><br>

            {% if document.type_id == "charter" %}
                {% include "telechat/group.html" %}
                <br><hr><br>
            {% endif %}

            <h2 id="writeup">Ballot Writeup</h2>
            <pre>
{{ writeup }}
    </pre>

            {% if downrefs %}
                <h2 id="downrefs">Downward References</h2>
                {% for ref in downrefs %}
                    <p>Add {{ref.target.name}}
                        ({{ref.target.std_level}} - {{ref.target.stream.desc}} stream)
                        to downref registry.<br>
                        {% if not ref.target.std_level %}
                            +++ Warning: The standards level has not been set yet!!!<br>
                        {% endif %}
                        {% if not ref.target.stream %}
                            +++ Warning: document stream has not been set yet!!!<br>
                        {% endif %}
                {% endfor %}</p>
            {% endif %}

        {% else %}
            <h3>No Documents on the Agenda</h3>
        {% endif %}

    </div>

{% endblock %}